package com.ynkbny.config;

import com.ynkbny.util.Res;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常拦截处理类
 *
 * @author Gaoju
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Res<String> handlerException(Exception e) {
        log.error("Exception: {0}", e);
        return Res.fail(e.getMessage());
    }

}
